package com.wzq.str;

public class Test {

    public static boolean validPalindrome(String s) {
        int i=0,j=s.length()-1;
        boolean isDelete = false;
        int markI=-1,markJ=-1;
        while(i < j){
            if(s.charAt(i) != s.charAt(j)){

                if(isDelete || (s.charAt(i) != s.charAt(j-1) && s.charAt(i+1) != s.charAt(j))){
                    if(markI == -1){
                        return false;
                    }else{
                        i = markI;
                        j = markJ;
                        markI=-1;
                        continue;
                    }

                }
                if(s.charAt(i) == s.charAt(j-1)){
                   if(s.charAt(i+1) == s.charAt(j) ){
                       markI = i+1;
                       markJ = j;
                   }
                   j--;
                }else{
                    i++;
                }
                isDelete=true;
            }
            i++;j--;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(validPalindrome("ebcbbececabbacecbbcbe"));
    }
}
